package res;

import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;

public class ResourceLoader 
{
    public static BufferedImage loadImage(String imageName)
    {
	BufferedImage img;
	ResourceLoader.class.getProtectionDomain().getCodeSource().getLocation();
	try 
	{
	    img = ImageIO.read(ResourceLoader.class.getResourceAsStream("img/"+imageName));
	} 
	catch (Exception e) 
	{
	    try
	    {
		img = ImageIO.read(ResourceLoader.class.getResourceAsStream(imageName));
	    }
	    catch(Exception e2)
	    {
		System.err.println("Failed to load "+imageName+"\n");
		return null;
	    }
	}
	BufferedImage fin = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
	fin.getGraphics().drawImage(img, 0, 0, null);
	return fin;
    }
}
